package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class SIN extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    double d = 0.0D;
    Object localObject = null;
    for (int i = 0; i < paramArrayOfObject.length; ++i)
    {
      localObject = paramArrayOfObject[i];
      if (localObject instanceof Number)
      {
        d = Math.sin(((Number)localObject).doubleValue());
        break;
      }
    }
    return FunctionHelper.parsePrimitiveDouble(d);
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "SIN(number): 计算给定角度的正弦值。\nNumber:待求正弦值的以弧度表示的角度。\n备注:\n    如果参数的单位是度，将其乘以PI()/180即可转换成弧度。\n示例:\nSIN(10)等于-0.544021111。\nSIN(45*PI()/180)等于0.707106781。";
  }

  public String getEN()
  {
    return "SIN(number): Returns the sine of the given angle.\nNumber is the angle in radians for which you want the sine.\n\nRemarks:\n    If your argument is in degrees, multiply it by PI()/180 or use the RADIANS function to convert it to radians.\n\nExample:\n   SIN(10) = -0.544021111\n   SIN(45*PI()/180) = 0.707106781";
  }
}